package RestaurantManagement;

import java.util.ArrayList;
import java.util.HashMap;

public class RestaurantBilling extends RestaurantBillingSystem {
    private HashMap<String, Meal> meals;

    public RestaurantBilling(HashMap<String, Meal> meals) {
        this.meals = meals;
    }

    @Override
    public String placeOrder(HashMap<String, Integer> mealQuantities) {
        String orderId = "ORDER" + (orders.size() + 1);
        orders.put(orderId, new HashMap<>(mealQuantities));
        return orderId;
    }

    @Override
    public double calculateBill(String orderId) {
        HashMap<String, Integer> order = orders.get(orderId);
        if (order == null) return 0.0;
        double total = 0.0;
        for (String mealName : order.keySet()) {
            Meal meal = meals.get(mealName);
            if (meal != null) {
                total += meal.getPrice() * order.get(mealName);
            }
        }
        return total;
    }
}